﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
  <link href="${ctx.resource}/css/shiftform.css" rel="stylesheet">
  <link href="${ctx.resource}/css/select2.css" rel="stylesheet">
  <link href="${ctx.resource}/css/select2-bootstrap.css" rel="stylesheet">
  <link href="${ctx.resource}/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
 
  <title></title>

</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>

  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default beast-panel beast-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/customer">用户管理</a></li>
          <li class="active">用户数据</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 beast-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 beast-panel-layout-right">

          <div class="beast-breadcrumb-wrapper">
            <div class="beast-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title="用户数据"></i>&nbsp;&nbsp;<span>用户数据&nbsp;-&nbsp;用户详情</span></h2>
            </div>
          </div>
          
          <div class="beast-toolbar-wrapper top-margin-20 clearfix">
            <div class="text-right" style="padding-top: 10px; padding-bottom: 10px; border-bottom: 2px solid #CCC; ">
              <button type="button" class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" onclick="window.location.href='${ctx.host}/customers'"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</button>
            </div>	
          </div>
          
          <div class="beast-breadcrumb-wrapper top-margin-20">
            
              <ul class="nav nav-pills beast-breadcrumb-nav">
                <li class="pull-left active"><a href="javascript:void(0);" data-toggle="tab" data-target="#customer-profile" data-loaded="true">基本信息</a></li>
                <li class="pull-left"><a href="${ctx.host}/customers/${customer.id}/attr" data-toggle="tab" data-target="#customer-attr">用户属性</a></li>
              </ul>
              <a id="customer-attr-operation" class="hidden" href="${ctx.host}/customers/${customer.id}/attr/edit" data-toggle="modal" data-target="#" style="position: absolute; right: 0px; top: 0px; margin-top: 10px; margin-right: 10px;">编辑</a>
          </div> 
          <!-- Tab panes -->
          <div class="tab-content">
            <div class="tab-pane fade active in" id="customer-profile" style="min-height: 100px;">
              <div class="form-horizontal bottom-margin-20">
              
                <div class="form-group">
                  <label class="col-xs-2 control-label">用户编号：</label>
                  <div class="col-xs-4 pull-left"><p class="form-control-static">${customer.code}</p></div> 
                  
                  <label class="col-xs-2 control-label">用户来源：</label>
                  <div class="col-xs-4 pull-left"><p class="form-control-static">${customer.source.description}</p></div>
                </div>
                
                <div class="form-group">
                  <label class="col-xs-2 control-label">登录手机：</label>
                  <div class="col-xs-4 pull-left"><p class="form-control-static">${customer.mobile}</p></div>
                  <label class="col-xs-2 control-label">账号状态：</label>
                  <div class="col-xs-4 pull-left"><p class="form-control-static"><label class="label label-${customer.auditStatus.css }">${customer.auditStatus.description}</label></p></div>
                </div>
                <div class="form-group">
						      <label class="col-xs-2 control-label">昵称：</label>
						      <div class="col-xs-4 pull-left">
						        <p class="form-control-static">${customer.profile.nickName}</p>
						      </div>    
						      <label class="col-xs-2 control-label">年龄：</label>
						      <div class="col-xs-4 pull-left">
						        <p class="form-control-static">${customer.profile.age}</p>
						      </div>
						    </div>
						    <div class="form-group">
						      <label class="col-xs-2 control-label">性别：</label>
						      <div class="col-xs-4 pull-left">
						        <p class="form-control-static">${customer.profile.sex.description}</p>
						      </div>
						      <label class="col-xs-2 control-label">所在地：</label>
						      <div class="col-xs-4 pull-left">
						        <p class="form-control-static">${customer.profile.city.name}</p>
						      </div>
						    </div>
              </div>
            </div>
            <div class="tab-pane fade earth-lazy-loading" id="customer-attr" style="min-height: 100px;">
              <img src="${ctx.resource}/images/spinner.gif" class="loading-icon">
            </div>
            
          </div>

          
          
          <div class="beast-breadcrumb-wrapper top-margin-20">
            <div class="beast-breadcrumb yellow clearfix">
              <h2>
                <span>社交账号</span>
              </h2>
            </div>
          </div> 
          
          <c:choose>
            <c:when test="${empty customer.socialAccounts }">
              <p class="margin text-center">暂无社交账号</p>
            </c:when>
            <c:otherwise>
		          <table class="table table-striped table-hover demo2do-table bottom-margin-20">
		            <thead>
		              <tr>
		                <th>社交账户类型</th>
		                <th>账号</th>
		                <th>昵称</th>
		                <th>粉丝数量</th>
		                <th>报价</th>
		                <th>链接</th>
		                <th>审核状态</th>
		                <th>操作</th>
		              </tr>
		            </thead>
		            <tbody>
		              <c:forEach var="socialAccount" items="${customer.socialAccounts}">
		              <tr>
		                <td>${socialAccount.type.description}</td>
		                <td>${socialAccount.code}</td>
		                <td>${socialAccount.nickName}</td>
		                <td>${socialAccount.fans}</td>
		                <%-- <td>￥&nbsp;<fmt:formatNumber value="${socialAccount.estimatePrice/100}" pattern="#.##"/></td> --%>
		                <td>￥&nbsp;<fmt:formatNumber value="${variable.value }" pattern="#.##"/></td>
		                <td><a href="${socialAccount.link}" target="_blank">${socialAccount.link}</a></td>
		                <td><span class="label label-${socialAccount.auditStatus.css}">${socialAccount.auditStatus.description}</span></td>
		                <td>
		                  <a href="${ctx.host}/customers/${customer.id}/social-account/${socialAccount.id}/edit" data-toggle="modal" data-target="#">编辑</a>
		                  <c:if test="${socialAccount.auditStatus eq 'AUDITING' }">
                        <a href="${ctx.host}/customers/${customer.id}/social-account/${socialAccount.id}/audit" data-toggle="modal" data-target="#">审核</a>
                      </c:if>
		                </td>
		              </tr>
		              </c:forEach>
		            </tbody>
		          </table>
            </c:otherwise>
          </c:choose>
          
          
          <div class="beast-breadcrumb-wrapper top-margin-20">
            <div class="beast-breadcrumb yellow clearfix">
              <h2>
                <span>财务信息</span>
              </h2>
            </div>
          </div> 
          
          <div class="form-horizontal bottom-margin-20">
            
            <div class="form-group">
              <label class="col-xs-2 control-label">账户余额：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static text-success">￥&nbsp;<fmt:formatNumber value="${customer.wallet.balance/100}" pattern="#.##"/>元</p></div>
              <label class="col-xs-2 control-label">账户总收益：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static text-success">￥&nbsp;<fmt:formatNumber value="${customer.wallet.totalIncome/100}" pattern="#.##"/>元</p></div>
            </div>
            <div class="form-group">
              <label class="col-xs-2 control-label">提现总计：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static text-success">￥&nbsp;<fmt:formatNumber value="${customer.wallet.cashOut/100}" pattern="#.##"/>元</p></div>
              <label class="col-xs-2 control-label">创建时间：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static text-info">&nbsp;<fmt:formatDate value="${customer.wallet.createTime}" pattern="yyyy-MM-dd HH:mm:ss" /></p></div>
            </div>
            
          </div>  
          
          <div class="beast-breadcrumb-wrapper top-margin-20">
            <div class="beast-breadcrumb yellow clearfix">
              <h2>
                <span>财务记录</span>
              </h2>
            </div>
          </div> 
          <div class="form-horizontal bottom-margin-20">
	          <c:choose>
	            <c:when test="${empty  walletRecords }">
	              <p class="margin text-center">暂无钱包记录</p>
	            </c:when>
	            <c:otherwise>
	              <table class="table table-striped table-hover demo2do-table bottom-margin-20">
	                <thead>
	                  <tr>
                      <th>描述</th>
	                    <th>时间</th>
	                    <th>金额</th>
	                  </tr>
	                </thead>
	                <tbody>
	                  <c:forEach var="walletRecord" items="${walletRecords}">
	                  
	                  <c:choose>
					   <c:when test="${walletRecord.type.alias  == 'cashout'}">  
					   	<tr>
						   <td><p>${walletRecord.type.description}</p></td>
		                    <td><fmt:formatDate value="${walletRecord.occurTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
		                    <td><p class="text-danger">-<fmt:formatNumber value="${walletRecord.money/100}" pattern="#.##"/>元</p> </td>
	                    </tr>
					   </c:when>
					   <c:otherwise> 
				   		<tr>
						   <td><p>${walletRecord.type.description}</p></td>
		                    <td><fmt:formatDate value="${walletRecord.occurTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
		                    <td><p><font color="#63CC00"><fmt:formatNumber value="${walletRecord.money/100}" pattern="#.##"/>元</font></p> </td>
	                    </tr>
					   </c:otherwise>
					   
					  </c:choose>
	                  
	                  </c:forEach>
	                </tbody>
	              </table>
	              
                <jsp:include page="/WEB-INF/include/page.jsp">
                  <jsp:param name="url" value="customers/${customer.id}" />
                </jsp:include>
                
	            </c:otherwise>
	          </c:choose>
          </div>
              
        </div>
      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/footer.jsp"%>
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <script src="${ctx.resource}/js/shiftform-ajax.js"></script>
  <script src="${ctx.resource}/js/select2.min.js"></script>
  <script src="${ctx.resource}/js/select2_locale_zh-CN.js"></script>
  <script src="${ctx.resource}/js/tab-layzing-loading.js"></script>
  <script src="${ctx.resource}/js/bootstrap-datetimepicker.js"></script>
  <script src="${ctx.resource}/js/bootstrap-datetimepicker.zh-CN.js"></script>
  <script src="${ctx.resource}/js/bootstrap.validate.js"></script>
  <script src="${ctx.resource}/js/bootstrap.validate.en.js"></script>
  <script>
    $(document).ready(function(){
       $('[data-toggle="tab"]').on('show.bs.tab', function(e) {
          
          // switch link
          var $current = $(e.target),
          $prev = $(e.relatedTarget),
          url = $(e.target).attr('href');
          $($current.data('target') + '-operation').removeClass('hidden');
          $($prev.data('target') + '-operation').addClass('hidden');
          
          var aa = $current.data('loaded');
          if(!aa) {
            setTimeout(function() {
                $current.tabLazyLoading(url);
            }, 1000);
          }
          
        });
    });
  </script>

</body>

</html>
